package org.shj.flink.sink;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.shj.flink.dto.TargetStaffDTO;

/**
 * @author Shen Huang Jian
 * @date 2020-08-05 17:03
 */
public class MyCustomizeSink extends RichSinkFunction<TargetStaffDTO> {

    private static int cnt = 0;


    @Override
    public void invoke(TargetStaffDTO value, Context context) throws Exception {
        System.out.println("========" + cnt);

        //context.
        cnt++;
        if(cnt % 5 == 0){
            throw new Exception("just for test");
        }
        System.out.println("sink: " + value);
    }

    @Override
    public void open(Configuration parameters) throws Exception {
        super.open(parameters);
    }

    @Override
    public void close() throws Exception {
        super.close();
    }
}
